package com.kehutong.repair.applet;

import com.kehutong.common.util.Token;
import com.kehutong.repair.entity.*;
import com.kehutong.repair.service.applet.AppletRepairsService;
import org.coraframework.inject.Inject;
import org.coraframework.json.JSONObject;
import org.coraframework.logger.Logger;
import org.coraframework.logger.LoggerFactory;
import org.coraframework.mvc.MvcAction;
import org.coraframework.mvc.http.Bean;
import org.coraframework.mvc.http.ReqMapping;
import org.coraframework.mvc.http.result.Result;

@MvcAction
@ReqMapping("/kht-bin/repairs")
public class RepairsAction {

    protected final Logger logger = LoggerFactory.getLogger(RepairsAction.class);

    @Inject
    private AppletRepairsService appletRepairsService;


    @ReqMapping("/get")
    public Object get(JSONObject jsonObject){
        return Result.success(appletRepairsService.get(jsonObject));
    }

//    @ReqMapping("/getSubscribe")
//    public Object getSubscribe(Token session){
//        return Result.success(getResultJSONObiect(session));
//    }

    @Bean(newInstance = true, copy = true)
    @ReqMapping("/save")
    public Object save(Token token, Repairs item, JSONObject jsonObject) throws Exception {
        return appletRepairsService.save(token, item, jsonObject);
    }

    @ReqMapping("/update")
    public Object update(Token token, JSONObject jsonObject) throws Exception {
        return appletRepairsService.update(token, jsonObject);
    }

    @ReqMapping("/reminder")
    public Object reminder(Token token, JSONObject jsonObject) throws Exception {
        return appletRepairsService.reminder(token, jsonObject);
    }

    @ReqMapping("/evaluation")
    public Object evaluation(Token token, JSONObject jsonObject) throws Exception {
        return appletRepairsService.evaluation(token, jsonObject);
    }

    @ReqMapping("/list")
    public Object list(Token token, JSONObject jsonObject) {
        return Result.success(appletRepairsService.list(token, jsonObject));
    }

    @ReqMapping("/remark")
    public Object remark(Token token, String remark, String id) throws Exception {
        return appletRepairsService.remark(token, remark, id);
    }

    @ReqMapping("/getRemark")
    public Object getRemark(String id){
        return appletRepairsService.getRemark(id);
    }
}
